<template>
  <div class="app-container">
    <!-- 图片上次参考项目列表 -->
    <h5 class="titleInfo">医院基础信息</h5>
    <el-form ref="form" class="form" :model="params" :rules="rules" label-width="180px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="医院名称" prop="name">
            <el-input
              v-model="params.name"
              placeholder="请输入医疗广告审查表中的医院名称"
              :disabled="$route.query.type==3||$route.query.type==2||$route.query.type==1"
            />
          </el-form-item>
        </el-col>
        <!--  -->
        <el-col v-if="$route.query.type==3 || $route.query.type==2" :span="24">
          <el-form-item label="创建人">
            <el-input v-model="params.createdBy" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col v-if="$route.query.type==3 || $route.query.type==2" :span="24">
          <el-form-item label="创建时间">
            <el-input v-model="params.createdAt" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="营业执照" prop="businessLicenseImage">
            <div v-if="$route.query.type==2 ||$route.query.type == 3">
              <img
                v-for="(item, index) in businessLicenseImage"
                :key="index"
                style="width: 250px;"
                :src="item.url"
                alt
                @click="diafun(item.url)"
              />
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="businessLicenseImage"
                :file-list="businessLicenseImage"
                type="file"
                :file-num="1"
                :datas="obj1"
                accept="jpeg、JPG、jpg、png"
                :disabled="$route.query.type==3"
              />
              <p>请上传加盖公章营业执照复印件，最多允许上传1个附件，支持格式：jpeg、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="营业执照有效期">
            <el-date-picker
              v-show="!params.checked"
              v-model="time"
              type="daterange"
              value-format="yyyy-MM-dd"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :disabled="$route.query.type==3||$route.query.type==2"
            />

            <el-checkbox
              v-model="params.checked "
              :disabled="$route.query.type==3||$route.query.type==2"
            >长期</el-checkbox>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="医疗机构许可证" prop="institutionLicenseImage">
            <div v-if="$route.query.type==2 ||$route.query.type == 3">
              <img
                v-for="(item, index) in institutionLicenseImage"
                :key="index"
                style="width: 250px;"
                :src="item.url"
                alt
                @click="diafun(item.url)"
              />
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="institutionLicenseImage"
                type="file"
                :file-list="institutionLicenseImage"
                :file-num="2"
                accept="jpeg、JPG、jpg、png"
                :disabled="$route.query.type==3"
              />
              <p>请上传医疗机构许可证复印件，最多允许上传2个附件，支持格式：jpeg、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="医疗广告审查表" prop="advertisingReviewImage">
            <div v-if="$route.query.type==2 ||$route.query.type == 3">
              <img
                v-for="(item, index) in advertisingReviewImage"
                :key="index"
                style="width: 250px;"
                :src="item.url"
                alt
                @click="diafun(item.url)"
              />
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="advertisingReviewImage"
                type="file"
                :file-list="advertisingReviewImage"
                :file-num="1"
                :disabled="$route.query.type==3"
                accept="JPG、jpg、png"
              />
              <p>请上传医疗广告审查表复印件，最多允许上传1个附件，支持格式：JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="合同" prop="contractImage">
            <div
              v-if="$route.query.type==2 ||$route.query.type == 3"
              style="word-wrap: break-word;"
            >
              <a
                v-for="(item, index) in contractImage"
                :key="index"
                style="margin: 0 10px;text-decoration: underline;color: blue;"
                :href="item.url"
                target="_blank"
                rel="noopener noreferrer"
              >{{ item.name }}</a>
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="contractImage"
                type="file"
                :file-list="contractImage"
                :file-num="5"
                :disabled="$route.query.type==3"
                accept="pdf、JPG、jpg、png"
              />
              <p>请上传合同，最多允许上传5个附件，支持格式：pdf、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 医院结算模式 -->
      <div class="divBar" />
      <h5 class="titleInfo">医院结算模式</h5>
      <el-row>
        <el-col :span="24">
          <el-form-item label="结算模式">
            <el-radio
              v-model="params.settlementType"
              :disabled="$route.query.type == 3||$route.query.type == 0||$route.query.type == 2"
              :label="0"
            >回款模式</el-radio>
            <el-radio
              v-model="params.settlementType"
              :disabled="$route.query.type == 3||$route.query.type == 0||$route.query.type == 2"
              :label="1"
            >预存款模式</el-radio>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="$route.query.type == 3 || $route.query.name == 'edit'">
          <el-form-item label="信用额度">
            <input v-model.number="params.creditLimit" type="number" />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 医院经营信息 -->
      <div class="divBar" />
      <h5 class="titleInfo">医院经营信息</h5>

      <el-row v-show="params.isOpenAccount=='0'">
        <el-col :span="12">
          <el-form-item label="法人姓名" :prop="params.isOpenAccount == '0' ? 'legalName' : ''">
            <el-input
              v-model="params.legalName"
              placeholder="请输入法人姓名"
              :disabled="params.accountOpenStatus==2 || $route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="法人身份证号" :prop="params.isOpenAccount == '0' ? 'identityCode' : ''">
            <el-input
              v-model="params.identityCode"
              placeholder="请输入法人证件号码"
              :disabled="params.accountOpenStatus==2||$route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="业务联系人" :prop="params.isOpenAccount == '0' ? 'subContactsName' : ''">
            <el-input
              v-model="params.subContactsName"
              placeholder="请输入法人姓名"
              :disabled="params.accountOpenStatus==2 || $route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系人手机号" :prop="params.isOpenAccount == '0' ? 'mobileId' : ''">
            <el-input
              v-model="params.mobileId"
              placeholder="请输入法人提现到银行卡的预留手机号"
              :disabled="params.accountOpenStatus==2 || $route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item
            label="法人证件正面"
            :prop="params.isOpenAccount=='0'?'frontPersonCertificateImage':''"
          >
            <div v-if="$route.query.type==2 ||$route.query.type == 3">
              <img
                v-for="(item, index) in frontPersonCertificateImage"
                :key="index"
                style="width: 250px;"
                :src="item.url"
                alt
                @click="diafun(item.url)"
              />
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="frontPersonCertificateImage"
                type="file"
                :file-list="frontPersonCertificateImage"
                :file-num="1"
                :datas="obj3"
                :disabled="$route.query.type==3 || params.accountOpenStatus==2"
                accept="jpeg、JPG、jpg、png"
              />
              <p>请上传合同，最多允许上传1个附件，支持格式：jpeg、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="法人证件反面"
            :prop="params.isOpenAccount=='0'?'reversePersonCertificateImage':''"
          >
            <div v-if="$route.query.type==2 ||$route.query.type == 3">
              <img
                v-for="(item, index) in reversePersonCertificateImage"
                :key="index"
                style="width: 250px;"
                :src="item.url"
                alt
                @click="diafun(item.url)"
              />
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="reversePersonCertificateImage"
                type="file"
                :file-list="reversePersonCertificateImage"
                :file-num="1"
                :datas="obj4"
                :disabled="$route.query.type==3 || params.accountOpenStatus==2 "
                accept="jpeg、JPG、jpg、png"
              />
              <p>请上传合同，最多允许上传1个附件，支持格式：jpeg、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 医院回款信息 -->
      <div class="divBar" />
      <h5 class="titleInfo">医院回款信息</h5>
      <el-row>
        <el-col :span="12">
          <el-form-item label="美美咖报单回款比率" prop="reimbursementRatio">
            <el-input
              v-model="params.reimbursementRatio"
              style="display: flex;"
              type="number"
              placeholder="请输入回款比率"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
            >
              <template slot="append" style="line-height: 34px;">%</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="金币结算比率">
            <el-input
              v-model="params.goldSilverRatio"
              style="display: flex;"
              type="number"
              placeholder="金币结算比率"
              :disabled="$route.query.type == 2 || $route.query.type == 3"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="传统报单回款比率" prop="normalReimbursementRatio">
            <el-input
              v-model="params.normalReimbursementRatio"
              style="display: flex;"
              type="number"
              placeholder="请输入回款比率"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
            >
              <template slot="append" style="line-height: 34px;">%</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col v-if="$route.query.type!=0" :span="24">
          <el-form-item label="回款比率生效时间">
            <el-date-picker
              v-model="params.time"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetime"
              placeholder="选择日期时间"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 医院入驻费信息 -->
      <div class="divBar" />
      <h5 class="titleInfo">医院入驻费信息</h5>
      <el-row>
        <el-col :span="24">
          <el-form-item label="入驻费" prop="settlementFee">
            <el-input
              v-model="params.settlementFee"
              placeholder="请输入入驻费"
              type="number"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="入驻费交款凭证" prop="feePaymentImage">
            <div
              v-if="$route.query.type==2 ||$route.query.type == 3"
              style="display: flex;flex-flow: wrap;"
            >
              <a
                v-for="(item, index) in feePaymentImage"
                :key="index"
                style="margin: 0 10px;text-decoration: underline;color: blue;"
                :href="item.url"
                target="_blank"
                rel="noopener noreferrer"
              >{{ item.name }}</a>
            </div>
            <div v-show="$route.query.type==0 ||$route.query.type == 1">
              <newUpload
                ref="feePaymentImage"
                type="file"
                :file-list="feePaymentImage"
                :file-num="5"
                :disabled="$route.query.type==3"
                accept="pdf、JPG、jpg、png"
              />
              <p>请上传入驻费交款凭证，最多允许上传5个附件，支持格式：pdf、JPG、jpg、png</p>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 传统报单分成信息 -->
      <div class="divBar" />
      <h5 class="titleInfo">传统报单分成信息</h5>
      <el-row>
        <el-col :span="24">
          <el-form-item label="分成模式">
            <!-- {{params.pattern.patternType}} -->
            <el-radio
              v-model="params.pattern.patternType"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
              :label="0"
            >未定义</el-radio>
            <el-radio
              v-model="params.pattern.patternType"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
              :label="2"
            >美美咖报单</el-radio>
            <el-radio
              v-model="params.pattern.patternType"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
              :label="1"
            >自定义</el-radio>
          </el-form-item>
        </el-col>
        <el-col :span="24" v-if="params.pattern.patternType">
          <el-form-item label="业绩推荐">
            <div class="inf">
              <table border="1" cellpadding="0" style="border-color: #ddd;" cellspacing="0">
                <th>会员推荐业绩</th>
                <th>一级推荐业绩（特约）</th>
                <th>一级推荐业绩（高级）</th>
                <th>一级推荐业绩(总监)</th>
                <th>一级推荐业绩(总经理)</th>
                <th>二级平推业绩</th>
                <th>二级推荐业绩</th>
                <tr>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomMember"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2 "
                      v-model="params.pattern.recomFirstGeneral"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomFirstAdvanced"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <!-- 新加 -->
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomFirstDirector"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomFirstGeneralManager"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomSecondGeneral"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.recomSecondAdvanced"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                </tr>
              </table>
            </div>
          </el-form-item>

          <el-form-item label="团队业绩">
            <div class="inf">
              <table border="1" cellpadding="0" style="border-color: #ddd;" cellspacing="0">
                <th>新晋总监/总经理</th>
                <th>推荐人</th>

                <tr>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.teamDirectorManager"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.teamRecommender"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                </tr>
              </table>
            </div>
          </el-form-item>

          <el-form-item label="大区业绩">
            <div class="inf">
              <table border="1" cellpadding="0" style="border-color: #ddd;" cellspacing="0">
                <th>新晋总经理</th>
                <th>推荐人</th>
                <th>原创总经理</th>
                <tr>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.largeNewManager"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.largeRecommender"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                  <td>
                    <el-input
                      :disabled="$route.query.type==2 ||$route.query.type == 3 || params.pattern.patternType==2"
                      v-model="params.pattern.largeOldManager"
                    >
                      <template slot="append" style="line-height: 34px;">%</template>
                    </el-input>
                  </td>
                </tr>
              </table>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- 其他信息 -->
      <div class="divBar" />
      <h5 class="titleInfo">其他信息</h5>
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注">
            <el-input
              v-model="params.remarks"
              style="width: 236px;"
              type="textarea"
              :rows="2"
              :disabled="$route.query.type==2 ||$route.query.type == 3"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <div v-if="$route.query.type==3" class="divBar" />
      <h5 v-if="$route.query.type==3" class="titleInfo">审核意见</h5>
      <el-row v-if="$route.query.type==3">
        <el-col :span="24">
          <el-form-item label="审核状态">
            <el-radio-group
              v-model="params.examineStatus"
              :disabled="$route.query.name == 'detail'"
            >
              <el-radio v-if="$route.query.name == 'detail'" label="0">待审核</el-radio>
              <el-radio label="1">审核通过</el-radio>
              <el-radio label="2">审核驳回</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="审核意见">
            <el-input
              v-model="params.auditOpinion"
              type="textarea"
              :rows="2"
              style="width: 236px;"
              :disabled="$route.query.name =='detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item v-if="$route.query.name !='detail'">
        <el-button
          v-if="$route.query.type!=2"
          style="margin:30px 0"
          type="primary"
          @click="subime"
        >立即提交</el-button>
      </el-form-item>
    </el-form>

    <el-dialog title="提示" :visible.sync="dialogVisible">
      <div style="width:500px;overflow: auto;">
        <img :src="imgSrc" style="width:100%;display:block;" alt />
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import newUpload from "@/components/imgUpload/index";
import hospitalEnter from "@/api/hospitalEnry";
const phoneReg = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入会员手机号"));
  } else {
    const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
    if (reg.test(value)) {
      callback();
    } else {
      return callback(new Error("手机格式错误"));
    }
  }
};
export default {
  components: {
    newUpload
  },

  data() {
    return {
      tableData: [{}],
      dialogVisible: false,
      imgSrc: "",
      obj1: {
        type:
          "BUSSINESS_LICENSE/" +
          (this.$route.query.id ? this.$route.query.id : new Date().getTime())
      },
      obj2: {
        type:
          "BANK_ACCOUNT_LICENCE/" +
          (this.$route.query.id ? this.$route.query.id : new Date().getTime())
      },
      obj3: {
        type:
          "ID_CARD_FRONT/" +
          (this.$route.query.id ? this.$route.query.id : new Date().getTime())
      },
      obj4: {
        type:
          "ID_CARD_BACK/" +
          (this.$route.query.id ? this.$route.query.id : new Date().getTime())
      },
      rules: {
        name: [
          {
            required: true,
            message: "请输入医院名称",
            trigger: "blur"
          }
        ],
        reimbursementRatio: [
          { required: true, message: "回款比率", trigger: "blur" }
        ],
        userType: [{ required: true, message: "商户类型", trigger: "blur" }],
        userName: [{ required: true, message: "商户名称", trigger: "blur" }],
        certType: [{ required: true, message: "证件类型", trigger: "blur" }],
        identityId: [{ required: true, message: "证件号码", trigger: "blur" }],
        isOpenAccount: [
          { required: true, message: "是否开户", trigger: "blur" }
        ],
        legalName: [{ required: true, message: "法人姓名", trigger: "blur" }],
        identityCode: [
          { required: true, message: "法人身份证号", trigger: "blur" }
        ],
        subContactsName: [
          { required: true, message: "业务联系人", trigger: "blur" }
        ],
        mobileId: [{ required: true, validator: phoneReg, trigger: "blur" }],
        settlementFee: [{ required: true, message: "入驻费", trigger: "blur" }],
        // 1.2.1版本再去掉校验
        // advertisingReviewImage: [
        //   { required: true, message: '上传文件', trigger: 'blur' }
        // ],
        businessLicenseImage: [
          {
            required: true,
            message: "上传营业执照url",
            trigger: "blur"
          }
        ],
        contractImage: [
          {
            required: true,
            message: "上传合同图片URL",
            trigger: "blur"
          }
        ],
        reversePersonCertificateImage: [
          {
            required: true,
            message: "上传身份证正面图片URL",
            trigger: "blur"
          }
        ],
        frontPersonCertificateImage: [
          {
            required: true,
            message: "上传身份证反面图片URL",
            trigger: "blur"
          }
        ],
        feePaymentImage: [
          {
            required: true,
            message: "上传入驻费交款凭证图片URL",
            trigger: "blur"
          }
        ],
        institutionLicenseImage: [
          {
            required: true,
            message: "上传医疗机构许可证图片URL",
            trigger: "blur"
          }
        ]
      },
      time: "",
      radio: "",
      advertisingReviewImage: [],
      businessLicenseImage: [],
      institutionLicenseImage: [],
      contractImage: [], // 合同图片URL
      frontPersonCertificateImage: [],
      reversePersonCertificateImage: [],
      feePaymentImage: [], // 入驻费交款凭证图片URL
      params: {
        settlementType: 1,
        pattern: {
          patternType: 0,
          recomMember: "",
          recomMember: "",
          recomFirstAdvanced: "",
          recomFirstDirector: "",
          recomFirstGeneralManager: "",
          recomSecondGeneral: "",
          recomSecondAdvanced: "",
          teamDirectorManager: "",
          teamRecommender: "",
          largeNewManager: "",
          largeRecommender: "",
          largeOldManager: ""
        },
        enteryAdd: 0,
        isOpenAccount: 0,
        isPermanent: 0,
        userType: 1,
        certType: 1,
        examineStatus: 1,
        hospitalInformationId: null,
        name: "", // 医院名称
        businessLicenseImage: [], // 营业执照url
        businessLicenseStartime: "", // 营业执照有效期开始时间yyyy-MM-dd
        businessLicenseEndtime: "", // 营业执照有效期结束时间yyyy-MM-dd
        institutionLicenseImage: [], // 医疗机构许可证图片URL
        advertisingReviewImage: [], // 医疗广告审查表图片URL
        contractImage: [], // 合同图片URL
        frontPersonCertificateImage: [],
        reversePersonCertificateImage: [],
        reimbursementRatio: "", // 回款比率
        settlementFee: "", // 入驻费
        feePaymentImage: [], // 入驻费交款凭证图片URL
        remarks: "" // 备注
      }
    };
  },
  watch: {
    "params.pattern.patternType": {
      deep: true,
      handler: function(val, oldV) {
        console.log(val);
        // if(!val){
        //   this.params.pattern.patternType =0
        // }
        if (val == 2) {
          console.log(val);
          this.params.pattern.recomMember = "15";
          this.params.pattern.recomFirstGeneral = "45";
          this.params.pattern.recomFirstAdvanced = "50";
          this.params.pattern.recomSecondGeneral = "3";
          this.params.pattern.recomSecondAdvanced = "5";
          this.params.pattern.recomFirstDirector = "53";
          this.params.pattern.recomFirstGeneralManager = "55";

          this.params.pattern.teamDirectorManager = "1.5";
          this.params.pattern.teamRecommender = "0.5";

          this.params.pattern.largeNewManager = "1";
          this.params.pattern.largeRecommender = "0.5";
          this.params.pattern.largeOldManager = "0.5";
          console.log(this.params.pattern);
          // this.params = JSON.parse(JSON.stringify(this.params))
        }
      }
    },
    "params.checked": {
      deep: true,
      handler: function(val, oldV) {
        console.log(val);
        if (val) {
          this.params.isPermanent = 1;
        } else {
          this.params.isPermanent = 0;
        }
      }
    }
  },
  created() {
    if (this.$route.query.type == 3) {
      // 审核页面
      this.$route.meta.title = "医院上架审核管理";
    } else if (this.$route.query.type == 0) {
      this.$route.meta.title = "医院入驻信息新增";
    } else if (this.$route.query.type == 1) {
      this.$route.meta.title = "医院入驻信息编辑";
    } else if (this.$route.query.type == 2) {
      this.$route.meta.title = "医院入驻信息详情";
    }
    if (this.$route.query.id) {
      this.params.hospitalInformationId = this.$route.query.id;
      this.detail();
    }
  },
  methods: {
    diafun(img) {
      this.imgSrc = img;
      this.dialogVisible = true;
    },
    subime() {
      //校验
      if (
        this.params.pattern.patternType != "0" ||
        this.params.pattern.patternType != "1"
      ) {
        // this.params.pattern.patternType = 0;
      }

      if (
        this.params.pattern.recomSecondAdvanced -
          0 +
          (this.params.pattern.teamDirectorManager - 0) +
          (this.params.pattern.recomFirstGeneralManager - 0) +
          (this.params.pattern.teamRecommender - 0) +
          (this.params.pattern.largeNewManager - 0) +
          (this.params.pattern.largeRecommender - 0) +
          (this.params.pattern.largeOldManager - 0) >
          (this.params.normalReimbursementRatio
            ? this.params.normalReimbursementRatio - 0
            : 0) &&
        this.params.pattern.patternType > 0
      ) {
        this.$message.warning("总分成奖励比率大于传统报单回款比率，不允许提交");
        return;
      }
      this.params.businessLicenseStartime = this.time ? this.time[0] : "";
      this.params.businessLicenseEndtime = this.time ? this.time[1] : "";
      // if (this.params.businessLicenseStartime == "") {
      //   this.$message({
      //     message: "时间不能为空",
      //     type: "warning"
      //   });
      //   return false;
      // }
      // 图片
      this.params.advertisingReviewImage = this.$refs.advertisingReviewImage.submitUpload();
      this.params.businessLicenseImage = this.$refs.businessLicenseImage.submitUpload();
      this.params.contractImage = this.$refs.contractImage.submitUpload();
      this.params.frontPersonCertificateImage = this.$refs.frontPersonCertificateImage.submitUpload()[0];
      this.params.reversePersonCertificateImage = this.$refs.reversePersonCertificateImage.submitUpload()[0];

      this.params.feePaymentImage = this.$refs.feePaymentImage.submitUpload();
      this.params.institutionLicenseImage = this.$refs.institutionLicenseImage.submitUpload();
      if (this.params.settlementFee < 0 || this.params.reimbursementRatio < 0) {
        this.$message({
          message: "金额不能小于0",
          type: "warning"
        });
        return false;
      }
      if (this.params.examineStatus !== null) {
        this.params.examineStatus = this.params.examineStatus + "";
        console.log(this.params.examineStatus);
      }

      this.$refs["form"].validate(valid => {
        if (valid) {
          if (
            this.params.reimbursementRatio < 0 ||
            this.params.settlementFee < 0
          ) {
            this.$message({
              message: "填写格式不对不能为负数",
              type: "warning"
            });
            return;
          }
          if (this.$route.query.type == 0) {
            this.addentery();
          }
          if (this.$route.query.type == 1) {
            // if (
            //   parseInt(new Date().getTime()) >
            //   parseInt(new Date(this.params.time).getTime())
            // ) {
            //   this.$message({
            //     message: "回款比率生效时间不能小于当前时间",
            //     type: "warning"
            //   });
            //   return;
            // }
            if (this.$route.query.name == "edit") {
              this.Examineedit();
            } else {
              this.editfun();
            }
          }
          if (this.$route.query.type == 3) {
            // 审核判断
            this.hospitalExamine();
          }
        } else {
          this.$message({
            message: "请填写完整的信息",
            type: "warning"
          });
          return false;
        }
      });
    },
    Examineedit() {
      const obj = { ...this.params };
      obj.settlementFee = obj.settlementFee + "";
      hospitalEnter.Examineedit(obj).then(res => {
        this.$message.warning(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    },
    hospitalExamine() {
      // type=3
      const obj = {
        examineId: this.params.examineId,
        examineStatus: this.params.examineStatus,
        auditOpinion: this.params.auditOpinion,
        isOpenAccount: this.params.isOpenAccount,
        creditLimit: this.params.creditLimit,
        settlementType: this.params.settlementType
      };
      console.log("选中", obj.examineStatus);
      hospitalEnter.Examine(obj).then(res => {
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    },

    addentery() {
      // type==0
      const obj = { ...this.params };
      obj.settlementFee = obj.settlementFee + "";
      hospitalEnter.addList(obj).then(res => {
        this.$message.warning(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    },
    editfun() {
      const obj = { ...this.params };
      obj.settlementFee = obj.settlementFee + "";
      hospitalEnter.editlsit(obj).then(res => {
        this.$message.warning(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    },
    detail() {
      const param = { id: this.params.hospitalInformationId - 0 };
      if (
        this.$route.query.type == 3 ||
        this.$route.query.name == "edit" ||
        this.$route.query.name == "detail"
      ) {
        hospitalEnter.hospitalExamineDetail(param).then(res => {
          this.datafun(res);
        });
      } else {
        hospitalEnter.detail(param).then(res => {
          this.datafun(res);
        });
      }
    },
    datafun(res) {
      if (res.data.code == 0) {
        //   console.log(res.data)
        //  res.data.data.pattern.patternType =       res.data.data.pattern.patternType?res.data.data.pattern.patternType:0
        res.data.data.pattern = res.data.data.pattern
          ? res.data.data.pattern
          : {
              patternType: 0,
              recomMember: "15",
              recomMember: "45",
              recomFirstAdvanced: "50",
              recomSecondGeneral: "3",
              recomSecondAdvanced: "5",
              teamDirectorManager: "1.5",
              teamRecommender: "0.5",
              largeNewManager: "1",
              largeRecommender: "0.5",
              largeOldManager: "0.5"
            };
        this.advertisingReviewImage = res.data.data.advertisingReviewImage
          ? this.imgsplit(res.data.data.advertisingReviewImage)
          : [];
        this.businessLicenseImage = res.data.data.businessLicenseImage
          ? this.imgsplit(res.data.data.businessLicenseImage)
          : [];
        this.contractImage = res.data.data.contractImage
          ? this.imgsplit(res.data.data.contractImage)
          : [];
        this.reversePersonCertificateImage = res.data.data
          .reversePersonCertificateImage
          ? this.imgsplit(res.data.data.reversePersonCertificateImage)
          : [];
        this.frontPersonCertificateImage = res.data.data
          .frontPersonCertificateImage
          ? this.imgsplit(res.data.data.frontPersonCertificateImage)
          : [];
        this.feePaymentImage = res.data.data.feePaymentImage
          ? this.imgsplit(res.data.data.feePaymentImage)
          : [];
        this.institutionLicenseImage = res.data.data.institutionLicenseImage
          ? this.imgsplit(res.data.data.institutionLicenseImage)
          : [];

        res.data.data.checked = res.data.data.isPermanent == 1;
        res.data.data.isExist = res.data.data.isExist + "";
        res.data.data.examineStatus = res.data.data.examineStatus + "";
        res.data.data.settlementType = res.data.data.settlementType - 0;
        this.params = res.data.data;
        this.params.issettlementType =
          res.data.data.settlementType == 1 ? true : false;
        console.log(this.params);
        this.time = [];
        if (this.params.businessLicenseStartime) {
          this.time.push(this.params.businessLicenseStartime);
          this.time.push(this.params.businessLicenseEndtime);
        }
      }
    },
    imgsplit(arrstr) {
      arrstr = arrstr.split(",");
      for (let i = 0; i < arrstr.length; i++) {
        arrstr[i] = {
          url: localStorage.getItem("imgUrlPrefix") + arrstr[i],
          name: arrstr[i]
        };
      }

      return arrstr;
    }
  }
};
</script>
<style lang="scss" scoped>
/deep/ .el-input__inner {
  // width: 300px !important;
}
/deep/ .el-input-group__append {
  line-height: 33px;
}
.app-container {
  padding: 0px !important;
}
.inf {
  display: flex;
}
p {
  padding: 0;
  margin: 0;
  color: #999;
}
</style>
